package com.example.kotlin_springboot.service

import com.example.kotlin_springboot.dao.TaskRepositry
import com.example.kotlin_springboot.entity.Task
import org.springframework.stereotype.Service


@Service
@org.springframework.transaction.annotation.Transactional
class TaskService(val taskRepositry: TaskRepositry){

    fun getAll() = taskRepositry.findAll()

    fun save(task: Task) = taskRepositry.save(task)

    fun delete(id:Long):Boolean{
        val found = taskRepositry.existsById(id)
        if (found){
            taskRepositry.deleteById(id)
        }
        return found
    }

}